library(ggplot2)
library(DT)
library(plotly)
library(PKI)
library(secure)

Introduction

This page is intended to provide a test to my ability to render RMarkdown documents and deploy to GithubPages using TravisCI

Show some R code

1 + 1
## [1] 2
5:10
## [1]  5  6  7  8  9 10
head(mtcars)
##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
## Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1

Show me a plot

carplot <- ggplot(data = mtcars, aes(
  x = wt,
  y = mpg,
  color = factor(vs)
)) +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_grid(. ~ am)
carplot

htmlwidgets

Plotly

ggplotly(carplot)

datatable

datatable(
  mtcars,
  extensions = c("Buttons",
                 "FixedColumns"#,
                 # "Responsive"
                 ),
  options = list(
    dom = "Bfrtip",
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
    scrollX = TRUE,
    fixedColumns = list(leftColumns = 1)
  )
)

Secure

Let’s try using Hadley’s Secure package

# secure::add_user("Alex Axthelm", local_key())
# secure::add_user("AlexAxthelm_gh", github_key("AlexAxthelm"))
# secure::add_user("travis", travis_key("AlexAxthelm/travis_render_test"))

This should show the results of secret data frame that was encrypted on a development machine, and rendered here on Travis.

# the secret data frame is iris.
Sys.getenv("OS")
## [1] ""
Sys.getenv("CONTINUOUS_INTEGRATION")
## [1] "true"
# Note that secure returns a list, so we need to do a list operator to get the actual data.
secret_data <- decrypt("this_is_iris")[[1]]
identical(secret_data, iris)
## [1] TRUE
enc_df <- mtcars %>% filter(am ==1)
secure::encrypt("enc_df", key = "abcdasdf", secret = enc_df)
## Merging with existing data
head(enc_df)
##    mpg cyl  disp  hp drat    wt  qsec vs am gear carb
## 1 21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4
## 2 21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
## 3 22.8   4 108.0  93 3.85 2.320 18.61  1  1    4    1
## 4 32.4   4  78.7  66 4.08 2.200 19.47  1  1    4    1
## 5 30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
## 6 33.9   4  71.1  65 4.22 1.835 19.90  1  1    4    1
remove(enc_df)
try(head(enc_df))
secure::decrypt("enc_df")
## $key
## [1] "abcdasdf"
## 
## $secret
##     mpg cyl  disp  hp drat    wt  qsec vs am gear carb
## 1  21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4
## 2  21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
## 3  22.8   4 108.0  93 3.85 2.320 18.61  1  1    4    1
## 4  32.4   4  78.7  66 4.08 2.200 19.47  1  1    4    1
## 5  30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
## 6  33.9   4  71.1  65 4.22 1.835 19.90  1  1    4    1
## 7  27.3   4  79.0  66 4.08 1.935 18.90  1  1    4    1
## 8  26.0   4 120.3  91 4.43 2.140 16.70  0  1    5    2
## 9  30.4   4  95.1 113 3.77 1.513 16.90  1  1    5    2
## 10 15.8   8 351.0 264 4.22 3.170 14.50  0  1    5    4
## 11 19.7   6 145.0 175 3.62 2.770 15.50  0  1    5    6
## 12 15.0   8 301.0 335 3.54 3.570 14.60  0  1    5    8
## 13 21.4   4 121.0 109 4.11 2.780 18.60  1  1    4    2